package com.system.Models;

import com.system.tools.Range;

public class Studentscore {
    private String id;
    private Double math;
    private Double english;

    private Range englishRange;

    private Range mathRange;

    private double score;

    public Studentscore(String id, Double math, Double english){
        this.id=id;
        this.math=math;
        this.english=english;
    }

    public Range getEnglishRange() {
        return englishRange;
    }

    public Range getMathRange() {
        return mathRange;
    }

    public void setEnglishRange(Range englishRange) {
        this.englishRange = englishRange;
    }

    public void setMathRange(Range mathRange) {
        this.mathRange = mathRange;
    }

    private Double getScoreNumber (String txt){
        if(txt.equals("")){
            return -1.0;
        }else {
            return Double.parseDouble(txt);
        }
    }
    public Studentscore(String id, String math, String english){
        this.id=id;
        this.math=getScoreNumber(math);
        this.english=getScoreNumber(english);
    }
    public Studentscore(String id) {this.id=id;
    }

    public Studentscore(String id, Range mathRange,Range englishRange){
        this.id = id;
        this.mathRange    = mathRange;
        this.englishRange = englishRange;
    }

    public void setMath(Double math) {
        this.math = math;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setScore(double score) {
        this.score = score;
    }

    public void setEnglish(Double english) {
        this.english = english;
    }
    public Double getEnglish(){
        return english;
    }

    public Double getMath() {
        return math;
    }

    public double getScore() {
        return score;
    }
    public String getMath(int i){
        if (this.math==null){
            return "";
        }
        if((int)Double.parseDouble(math.toString())==math){
            int a =  (int)Double.parseDouble(math.toString());
            return Integer.toString(a);
        }
        return math.toString();
    }
    public String getEnglish(int i){
        if (this.english==null){
            return "";
        }

        if((int)Double.parseDouble(english.toString())==english){
            int a =  (int)Double.parseDouble(english.toString());
            return Integer.toString(a);
        }
        return english.toString();
    }

    public String getId() {
        return id;
    }
}
